/**
 * 财务医保表-小计表
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){
    console.log('------$scope.menuId1-----', $scope.menuId);
    console.log('------$scope.buttonArr1-----', $scope.buttonArr);

    $scope.bindBtn = function(event) {
        var datas = $scope.getSelectedRows();
        switch(event){
            case 'event-to-classify':
            {
                window.top.add_tab("小计部门维护","/indexCommonOfMenu?menuId=10337");
                break;
            }
            case 'event-to-export':
            {
                $scope.doExport('/api/inter/tcwFinanceSalaryTotal/exportByMiTotal');
                break;
            }
            case 'event-to-count'://统计生成
            {
                layer.open({
                    shadeClose:true,
                    title: '选择月份',
                    content: `
								<form class="layui-form">
								  <div class="layui-form-item">
									 <input type="text" class="layui-input" id="choose_month" placeholder="选择月份">
								  </div>
								</form>
							`,
                    success: function(layero, index) {},
                    yes: function (index, layero) {
                        layer.msg('处理中', {
                            icon: 16,shade: 0.01
                        });
                        var countMonth = $('#choose_month').val();
                        $http.post('/api/inter/tcwFinanceSalaryTotal/updateTotalByCountMonth', {}, {params: {countMonth:countMonth}})
                            .success(function (data) {
                                if (data.code == 0) {
                                    layer.msg('成功！');
                                    setTimeout(function(){
                                        layer.closeAll();
                                        location.reload();
                                    }, 1000);
                                } else {
                                    layer.msg(data.msg);
                                    layer.closeAll();
                                }
                            })
                            .error(function(result){
                                layer.close();
                                layer.msg("操作失败，请稍后再试！", {icon: 2});
                            });
                    }
                });
                layui.use(function(){
                    var laydate = layui.laydate;
                    // 年月选择器
                    laydate.render({
                        elem: '#choose_month',
                        type: 'month'
                    });
                });
                break;
            }


        };
    }
}




